package com.huike.web.controller.clues;

import com.huike.clues.domain.TbRulePool;
import com.huike.clues.service.ITbRulePoolService;
import com.huike.common.annotation.Log;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author EthanRuins
 * @date 2023/7/13
 * @apiNote
 */
@RestController
@RequestMapping("/rule/pool")
@Api(tags = "线索池规则接口")
@AllArgsConstructor
public class TbRulePoolController extends BaseController {
    private final ITbRulePoolService rulePoolService;

    @PreAuthorize("@ss.hasPermi('system:pool:list')")
    @GetMapping("/{type}")
    @ApiOperation(value = "获取规则基础信息")
    public AjaxResult<TbRulePool> getByType(@PathVariable String type) {
        return AjaxResult.success(rulePoolService.getByType(type));
    }

    @PreAuthorize("@ss.hasPermi('system:pool:update')")
    @PutMapping
    @ApiOperation(value = "修改线索池规则")
    @Log(title = "修改线索池规则", businessType = BusinessType.UPDATE)
    public AjaxResult<Integer> update(@RequestBody TbRulePool rulePool) {
        return toAjax(rulePoolService.update(rulePool));
    }
}
